<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>基本信息</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript" src="${ctxStatic }/js/wsxx.js"></script>
		<script type="text/javascript" src="${ctxStatic }/js/idcard.js"></script>
		
		<script type="text/javascript">
			$(function(){
				var m = decodeURI(getQueryString2("dojk"))
				if(m != 'null'){	
					$("#dojk").val(m);
				}
				var n = decodeURI(getQueryString2("lccp_id"))
				if(n != 'null'){	
					$("#lccp_id").val(n);
				}
				
				if("${error}" != ""){
					$(".jbxxrgh_up").html("错误：${error}");
				}
				else{
					$(".jbxxrgh_up").hide();
				}
				$.validator.setDefaults({
					submitHandler : function(form) {
						form.submit();
					}
				});
				
				// 身份证号码验证
				jQuery.validator.addMethod("isIdCardNo", function(value, element) {
					return this.optional(element) || idCardNoUtil.checkIdCardNo(value);
				}, "请正确输入您的身份证号码");
				
				// 联系电话(手机/电话皆可)验证
				jQuery.validator.addMethod("isPhone", function(value, element) {
					var length = value.length;
					var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
					var tel = /^\d{3,4}-?\d{7,9}$/;
					return this.optional(element)
							|| (tel.test(value) || mobile.test(value));

				}, "请正确填写您的联系电话");

				// 开始验证
				$('#hyxxForm').validate({

					rules : {
						hyxm : "required",
						csrq : "required",
						sfzh : {
							required : true,
							isIdCardNo : true
						},
						lxdh : {
							required : true,
							isPhone : true
						}
					},

					messages : {
						hyxm : "请输入会员姓名",
						csrq : "出生日期必选",
						sfzh : {
							required : "请输入身份证号",
							isIdCardNo : "请输入合法的身份证号"
						},
						lxdh : {
							required : "请输入联系电话",							
							isPhone : "请输入合法的电话号码"
						}
					},

					focusInvalid : false,
					onkeyup : false
				});
				
				$("#sfzh").blur(function(){
					var v = $("#sfzh").val();
					if(v.length ==15 ){
						var tmpStr = v.substring(6, 12);
						tmpStr = "19" + tmpStr;
						tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6);
						$("#csrq").val(tmpStr);
					}
					if(v.length ==18){
						var tmpStr = v.substring(6, 14);						
						tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6);
						$("#csrq").val(tmpStr);						
					}
				})
				
				$("#btnSave").click(function() {
					$("#hyxxForm").submit();
				});
			});	

		</script>
	</head>
<body>
<div class="header_tit">
	<div class="header_titbox">
    	<a class="tit_home" href="${ctx }/my/index">返回账户首页</a>
        <h2 class="header_tit1">我的财富</h2>
        >
        <h3 class="header_tit2">完善信息</h3>
        >
        <h4 class="header_tit3">基本信息</h4>
    </div>
</div>
<div class="jbxx_box">
	<div class="jbxx_content clearfix">
		<c:if test="${dojk == '0'}">
    	<div class="jbxx_navbox">
        	<div class="jbxx_tit">完善信息</div>
            <ul>
                <li><a href="${ctx }/my/hyxx">基本信息</a></li>
                <li><a href="${ctx }/my/hyxx?flag=1">个人信誉借款信息</a></li>
                <li><a href="${ctx }/my/hyxx?flag=2">汽车抵押借款信息</a></li>
                <li><a href="${ctx }/my/hyxx?flag=3">房产抵押借款信息</a></li>
                <li><a href="${ctx }/my/hyxx?flag=4">企业信誉借款信息</a></li>
            </ul>
        </div>
        </c:if>
        <div class="jbxx_rightbox">
        	<p class="jbxxrgh_up" >${error} 温馨提示：${(error != '')? error: "基本信息为必填选项 "}</p>
        	<div class="jbxxrgh_down">
				<h3>基本信息</h3>
				<form:form id="hyxxForm" name="hyxxForm" modelAttribute="hyxx" method="post" action="${ctx }/my/savehyxx">
                <div class="jbxx_box">
                	<div class="jbxx_row clearfix">
                		<input type="hidden" id="id" name="id" value="${sessionScope.hy_id}"/>
                		<input type="hidden" id="flag" name="flag" value="0"/>
                		<input type="hidden" id="dojk" name="dojk" value="${dojk}"/>
                		<input type="hidden" id="jklx" name="jklx" value="${jklx}"/>
                		<input type="hidden" id="lccp_id" name="lccp_id" value="${lccp_id}"/>
                    	<label class="jbxx_rowlabel">姓名：</label>
                        <input class="jbxx_input" type="text" id="hyxm" name="hyxm" value="${hyxx.hyxm }"/>
                    </div>
                    <div class="jbxx_row clearfix">
                    	<label class="jbxx_rowlabel">性别：</label>
                        <select class="jbxx_xb" id="sex" name="sex" >
  							<option value="男" ${(hyxx.sex=='男') ? "selected=\"selected\"" : ""}>男</option>
  							<option value="女" ${(hyxx.sex=='女') ? "selected=\"selected\"" : ""}>女</option>
						</select>
                    </div>
                    <div class="jbxx_row clearfix">
                    	<label class="jbxx_rowlabel">身份证号：</label>
                        <input class="jbxx_input" type="text" id="sfzh" name="sfzh" value="${hyxx.sfzh }"/>
                    </div>
                    <div class="jbxx_row clearfix">
                    	<label class="jbxx_rowlabel">联系电话：</label>
                        <input class="jbxx_input" type="text" id="lxdh" name="lxdh" value="${hyxx.lxdh }"/>
                    </div>
                    <div class="jbxx_row clearfix">
                    	<label class="jbxx_rowlabel">出生日期：</label>
                        <input class="Wdate jbxx_input" type="text" id="csrq" name="csrq" value="${hyxx.csrq }" onclick="WdatePicker({isShowClear:false,readOnly:true,dateFmt:'yyyy-MM-dd'})" style="height:30px;border:1px solid #dcdcdc" />
                    </div>
               </div>
               </form:form>
            </div>
            <button class="jbxx_btn" id="btnSave" >保存</button>
        </div>
    </div>
</div>
</body>
</html>